00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OggFLACPP__DECODER_H
00021 #define OggFLACPP__DECODER_H
00022
00023 #include "export.h"
00024
00025 #include "OggFLAC/stream_decoder.h"
00026
00027 #include "FLAC++/decoder.h"
00028
00029
00057 namespace OggFLAC {
00058 namespace Decoder {
00059
00060
00061
00062
00063
00064
00065
00079 class OggFLACPP_API Stream {
00080 public:
00081 class OggFLACPP_API State {
00082 public:
00083 inline State(::OggFLAC__StreamDecoderState state): state_(state) { }
00084 inline operator ::OggFLAC__StreamDecoderState() const { return state_; }
00085 inline const char *as_cstring() const { return ::OggFLAC__StreamDecoderStateString[state_]; }
00086 protected:
00087 ::OggFLAC__StreamDecoderState state_;
00088 };
00089
00090 Stream();
00091 virtual ~Stream();
00092
00093 bool is_valid() const;
00094 inline operator bool() const { return is_valid(); }
00095
00096 bool set_serial_number(long value);
00097 bool set_metadata_respond(::FLAC__MetadataType type);
00098 bool set_metadata_respond_application(const FLAC__byte id[4]);
00099 bool set_metadata_respond_all();
00100 bool set_metadata_ignore(::FLAC__MetadataType type);
00101 bool set_metadata_ignore_application(const FLAC__byte id[4]);
00102 bool set_metadata_ignore_all();
00103
00104 State get_state() const;
00105 FLAC::Decoder::Stream::State get_FLAC_stream_decoder_state() const;
00106 unsigned get_channels() const;
00107 ::FLAC__ChannelAssignment get_channel_assignment() const;
00108 unsigned get_bits_per_sample() const;
00109 unsigned get_sample_rate() const;
00110 unsigned get_blocksize() const;
00111
00112 State init();
00113
00114 void finish();
00115
00116 bool flush();
00117 bool reset();
00118
00119 bool process_single();
00120 bool process_until_end_of_metadata();
00121 bool process_until_end_of_stream();
00122 protected:
00123 virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes) = 0;
00124 virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
00125 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00126 virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
00127
00128 ::OggFLAC__StreamDecoder *decoder_;
00129 private:
00130 static ::FLAC__StreamDecoderReadStatus read_callback_(const ::OggFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
00131 static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
00132 static void metadata_callback_(const ::OggFLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00133 static void error_callback_(const ::OggFLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
00134
00135
00136 Stream(const Stream &);
00137 void operator=(const Stream &);
00138 };
00139
00140
00141
00142 };
00143 };
00144
00145 #endif